import { createRouter, createWebHistory } from 'vue-router'
import { constantRoute } from './routes'

function VueRouter() {
  const router = createRouter({
    history: createWebHistory('/screen'), // 需要与主应用的activeRule一致
    routes: constantRoute,
    // 滚动行为
    scrollBehavior() {
      return {
        left: 0,
        top: 0,
      }
    }
  })
  // nprogress.configure({ showSpinner: false })
  // //全局前置守卫
  // router.beforeEach(async (to: any, from: any, next: any) => {
  //   // nprogress.start()
  //   next()
  // })
  // //全局后置守卫
  // router.afterEach((to: any, from: any) => {
  //   document.title = `${setting.title} - ${to.meta.title}`
  //   // nprogress.done()
  // })
  return router
}

export { VueRouter }